package com.gitee.wsl.compose.ui.popup.hints

import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue

@Stable
class Hint internal constructor() {

    internal var content: @Composable () -> Unit by mutableStateOf({})
}

@Composable
fun rememberHint(content: @Composable () -> Unit): Hint {
    return remember {
        Hint().also { it.content = content }
    }
}


/**
 *val coroutineScope = rememberCoroutineScope()
 *     val hintController = rememberHintController(
 *         overlay = Brush.linearGradient(
 *             listOf(
 *                 Color.Blue.copy(alpha = 0.5f),
 *                 Color.Red.copy(alpha = 0.5f),
 *             )
 *         )
 *     )
 *
 *     val topAppBarHint = rememberHintContainer {
 *         OutlinedButton(
 *             onClick = {
 *                 hintController.dismiss()
 *             }
 *         ) { Text("Hint for TopAppBar") }
 *     }
 *     val topAppBarActionHintAnchor = rememberHintAnchorState(topAppBarHint)
 *
 *     val actionHint = rememberHintContainer {
 *         Text("Hint for Action")
 *     }
 *     val actionHintAnchor = rememberHintAnchorState(actionHint)
 *
 *     val bottomNavigationHint = rememberHintContainer {
 *         Row(
 *             verticalAlignment = Alignment.CenterVertically,
 *         ) {
 *             Spacer(Modifier.size(32.dp).background(Color.Magenta, CircleShape))
 *             Spacer(Modifier.size(8.dp))
 *             Text("Hint for BottomNavigation")
 *         }
 *     }
 *     val bottomNavigationHintAnchor = rememberHintAnchorState(bottomNavigationHint)
 *
 *     MaterialTheme {
 *         Scaffold(
 *             topBar = {
 *                 TopAppBar(
 *                     windowInsets = AppBarDefaults.topAppBarWindowInsets,
 *                     title = {
 *                         Text("TopAppBar")
 *                     },
 *                     actions = {
 *                         IconButton(
 *                             modifier = Modifier
 *                                 .hintAnchor(topAppBarActionHintAnchor, CircleShape),
 *                             onClick = {
 *                                 coroutineScope.launch {
 *                                     hintController.show(topAppBarActionHintAnchor)
 *                                 }
 *                             },
 *                         ) {
 *                             Icon(
 *                                 Icons.Filled.Search,
 *                                 contentDescription = "Localized description",
 *                             )
 *                         }
 *                     }
 *                 )
 *             },
 *             bottomBar = {
 *                 BottomNavigation(
 *                     windowInsets = BottomNavigationDefaults.windowInsets,
 *                 ) {
 *                     listOf(
 *                         "Home" to Icons.Filled.Home,
 *                         "Favourite" to Icons.Outlined.Favorite,
 *                         "Settings" to Icons.Outlined.Settings,
 *                     ).forEachIndexed { index, (title, icon) ->
 *                         BottomNavigationItem(
 *                             modifier = if (index == 0) {
 *                                 Modifier.hintAnchor(
 *                                     bottomNavigationHintAnchor,
 *                                     shape = RoundedCornerShape(50f),
 *                                 )
 *                             } else {
 *                                 Modifier
 *                             },
 *                             icon = { Icon(icon, contentDescription = null) },
 *                             label = { Text(title) },
 *                             selected = index == 1,
 *                             onClick = {
 *                                 if (index == 0) {
 *                                     coroutineScope.launch {
 *                                         hintController.show(bottomNavigationHintAnchor)
 *                                     }
 *                                 }
 *                             },
 *                         )
 *                     }
 *                 }
 *             }
 *         ) {
 *             Box(
 *                 modifier = Modifier.fillMaxSize(),
 *                 contentAlignment = Alignment.Center,
 *             ) {
 *                 Button(
 *                     modifier = Modifier
 *                         .hintAnchor(actionHintAnchor, RoundedCornerShape(16.dp))
 *                         .padding(4.dp),
 *                     onClick = {
 *                         coroutineScope.launch {
 *                             hintController.show(
 *                                 topAppBarActionHintAnchor,
 *                                 actionHintAnchor,
 *                                 bottomNavigationHintAnchor,
 *                             )
 *                         }
 *                     },
 *                 ) {
 *                     Text("Action")
 *                 }
 *             }
 *         }
 *     }
 *
 */